package com.wenhao.xwbank;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author Wenhao Tong
 * @create 2021-08-28 20:12
 */
public class Main1 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String[] res;

        int _input_size = 0;
        _input_size = Integer.parseInt(in.nextLine().trim());
        String[] _input = new String[_input_size];
        String _input_item;
        for(int _input_i = 0; _input_i < _input_size; _input_i++) {
            try {
                _input_item = in.nextLine();
            } catch (Exception e) {
                _input_item = null;
            }
            _input[_input_i] = _input_item;
        }

        res = new Solution1().delMinFrequencyChar(_input);
        for(int res_i=0; res_i < res.length; res_i++) {
            System.out.println(String.valueOf(res[res_i]));
        }

    }
}

class Solution1 {
    /* Write Code Here */
    public String[] delMinFrequencyChar(String[] input) {
        String[] res = new String[input.length];
        for (int k = 0;k < input.length;k++) {
            String s = input[k];
            Map<Character,Integer> map = new HashMap<>();
            for (int i = 0;i < s.length();i++) {
                char c = s.charAt(i);
                if (map.containsKey(c)) {
                    map.put(c,map.get(c) + 1);
                } else {
                    map.put(c,1);
                }
            }
            int min = 0;
            for (Map.Entry<Character,Integer> entry : map.entrySet()) {
                if (min == 0) {
                    min = entry.getValue();
                } else {
                    min = Math.min(min,entry.getValue());
                }
            }
            StringBuilder result = new StringBuilder();
            for (int i = 0;i < s.length();i++) {
                if (map.get(s.charAt(i)) > min) {
                    result.append(s.charAt(i));
                }
            }
            res[k] = result.toString();
        }
        return res;
    }
}
